package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private ImageView mIvPic;
    MyScrollView mSv;
    private TextView tv_del;
    private ListView mLv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        initView();
        initEvent();
              mIvPic.scrollTo(200,200);//设置绝对偏移值
              mIvPic.scrollBy(200,200);//相对当前这个位置偏移
        mSv.scrollTo(100,0);
    }

    private void initEvent() {
        //获取MyScrollView中的删除按钮，并设置他的点击事件


    }

    private void initView() {
        mIvPic = findViewById(R.id.iv_pic);
        mSv = findViewById(R.id.mSv);
        mLv = findViewById(R.id.lv_list);
        mLv.setAdapter( new MyAdapter());

    }
    class  MyAdapter extends BaseAdapter{

        @Override
        public int getCount() {
            return 5;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view  =View.inflate(MainActivity.this,R.layout.list_item,null);
            tv_del=view.findViewById(R.id.tv_del);
            tv_del.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(MainActivity.this, "已删除", Toast.LENGTH_SHORT).show();            }
            });

            return view;
        }
    }

}
